#!/bin/bash

##全局变量
version=$1
#version=1.19.4;
#--------------------------------#
inspath=/home/sunqian
cpu_num=`grep -c "processor" /proc/cpuinfo`; #CPU核数
ip_addr=`ifconfig|grep inet|awk '{print $2}'|awk 'NR==1'` #ip地址
osType=`cat /etc/os-release|grep ID |awk NR==1|awk -F \" '{print $2}'`
basearch=`arch`
#--------------------------------#
if [ "$basearch" == "aarch64" ]
then
basearch=arm64
fi
cd $inspath
wget https://studygolang.com/dl/golang/go$version.linux-$basearch.tar.gz

tar -xvf go$version.linux-$basearch.tar.gz
ln -s $inspath/go /opt/go
echo -e "export PATH\nexport GOROOT=/opt/go\nexport GoPath=$GOROOT/bin\nPATH=$PATH:$GoPath" >> /root/.bash_profile
go env -w GOPROXY=https://goproxy.cn,direct
go env -w GOSUMDB=off   #关闭包的有效性验证
go env -w GOSUMDB="sum.golang.google.cn"  #也可设置国内提供的sum 验证服务

source /root/.bash_profile



